package com.android.plc.ui.manager;

import android.content.ContentResolver;
import android.content.Context;
import android.database.Cursor;

import com.android.plc.R;
import com.android.plc.classholder.BasicItem;
import com.android.plc.provider.PLC;
import com.android.plc.provider.PLC.Profiles;
import com.android.plc.ui.IBaseManager;
import com.android.plc.ui.adapter.ProfileAdapter;

public class ProfileListManager implements IBaseManager
{
	private ProfileAdapter mProfileList;
	private Context mContext;

	public ProfileListManager(Context context)
	{
		mContext = context;
		initAdapter(null);
	}

	private void initAdapter(BasicItem profile)
	{
		Cursor cursor_new = query(profile);
		mProfileList = new ProfileAdapter(mContext, cursor_new, R.layout.profile_item, new String[] { Profiles.NAME },
				new int[] { R.id.title }, false);
	}

	public void onBasicItemSelected(Manager mgr, BasicItem item, boolean admin)
	{
	}

	public void setAdapter(ProfileAdapter mProfileList)
	{
		this.mProfileList = mProfileList;
	}

	public ProfileAdapter getAdapter()
	{
		return mProfileList;
	}

	public Cursor query(BasicItem profile)
	{
		ContentResolver resolver = mContext.getContentResolver();
		return  resolver.query(PLC.Profiles.CONTENT_URI, PLC.PEOFILES_PROJECTION, null, null, null);

	}
}